{if $full_page}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{$title}</title>
<link rel="stylesheet" href="Res/boot/css/bootstrap.min.css" type="text/css" media="screen" />
<link rel="stylesheet" href="Res/boot/css/bootstrap-theme.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="Res/js/jquery.cookie.js"></script>
<script type="text/javascript" src="Res/boot/js/bootstrap.min.js"></script>
<script type="text/javascript" src="Res/js/listTable.js"></script>
<link rel="stylesheet" href="Res/css/page.css" type="text/css" />
<link rel="stylesheet" href="Res/css/global.css" type="text/css" />
<!-- 引用kind的textarea-->
<link rel="stylesheet" href="Res/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="Res/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="Res/kindeditor/lang/zh_CN.js"></script>


{literal}
<style>
    .listDiv{margin:0 auto;}  
</style>
{/literal}
</head>
<body>
<div class="container-fluid">
    <div class="panel panel-info"> 
        <div class="panel-heading">
            <span class="cp_title">{$title}</span>
            <div class="add_cp">
                    <a href="index.php?c=storytitle&m=view">返回标题列表</a>
            </div>
         </div>
         <div class="panel-body">
            <div class="text-center">
                <h3>{$title_name}</h3>
                <input type='hidden' value='{$tid}' id='tid'/>
                <input type='button' class="btn btn-default" value="测试" id='test' />
            </div>
         </div>
    </div>
{/if}
    <div class="listDiv" id="listDiv" style="padding-bottom: 20px;margin-bottom: 20px;">
        {foreach from=$data.pageData item=row}
        <div class="panel panel-default" id="panel{$row.cid}">
            <div class="panel-body">
                {$row.content}
            </div>
            <div class="panel-footer">
                <div style="float:left">
                    <button class="btn btn-warning btn-xs" onclick="showModal({$row.cid})">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </button>
                    <button class="btn btn-warning btn-xs" title="双击删除,无需确认" ondblclick="dbRemove({$row.cid})">
                        <span class="glyphicon glyphicon-trash"></span>
                    </button>
                </div>
                <div style="float:right">
                    <a href="{$row.ori_url}#{$row.floorNum}" target="_blank">原贴地址</a>
                    采集时间:{$row.in_time_format},发表时间:{$row.restime_format}{$row.floor}
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
        {/foreach}
        <div class="panel panel-info">
                <div class="panel-footer">
                    <div class="iPageHtml">{$data.pageHtml}</div>
                <div class="clearfix"></div>
                </div>
        </div>
    </div>
{if $full_page}
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:800px;padding-bottom:20px;">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                  &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">
               修改段落
            </h4>
            
         </div>
         <div class="modal-body">
            <!--style给定宽度可以影响编辑器的最终宽度-->
            <textarea id="myEditor" style="width:100%;height:100%">                
            </textarea>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">关闭
            </button>
            <button type="button" id="readsave" class="btn btn-primary">
               提交更改
            </button>
             <input type="hidden" id="cid" value="" />
         </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   
</div>
<div style="clear:both;"></div>
{literal}
<script type="text/javascript">
    //声名变量
    var cookie_page = 'read_list_page';
    //实例化编辑器
    var editor = KindEditor.create('textarea[id="myEditor"]');
    $(function(){
        var tid = $("#tid").val();
        listTable.filter.tid = tid;//初使主题ID
        var cookie_json = $.cookie(cookie_page + tid);
        var cookieObj = JSON.parse(cookie_json);
        if(cookieObj.tid == tid) {
            listTable.showPage(cookieObj.page);
        }
        $("#myModal").modal({"keyboard":true,'show':false});
        $("#readsave").click(function(){
            var cid = $("#cid").val();
            var content = editor.html();
            if(cid == '') {
                alert("请刷新页面,再试");
                return false;
            }
            var url = 'index.php?c=storyread&m=save';
            var pp = {};
            pp.cid = cid;
            pp.content = content;
            $.post(url, pp, function(json){
                if(json.status == 0) {
                    $("#panel" + cid).find(".panel-body").html(content);
                    $("#myModal").modal("hide");
                } else {
                    alert(json.msg);
                }
            }, 'json');
        });
        $("#test").click(function(){    
            var tid = $("#tid").val();
            var cookie_json = $.cookie(cookie_page + tid);
            var cookieObj = JSON.parse(cookie_json);
            console.log(cookieObj);
            var data = listTable.filter;
            console.log(data);
        });
    });
    function pageNext(page) {
        var pp = {};
        var tid = $("#tid").val();
        pp.tid = tid;
        pp.page = page;
        var str = JSON.stringify(pp);
        $.cookie(cookie_page + tid, str, {'expires':7});
        listTable.showPage(page);
    }
    function showModal(cid) {
        $("#cid").val(cid);
        $.ajaxSetup({'async': false});
        var url = "index.php?c=storyread&m=get&ajax=1&id=" + cid;
        var content = '';
        $.get(url,function(data){
            if(data.status == 0) {
               content = data.msg.content;               
            } else {
                alert(data.msg);
            }                       
        }, 'json');
        editor.html(content);
        $("#myModal").modal("show");        
    }
    function dbRemove(cid) {
        del(cid);
    }
    function del(cid){
        var url = "index.php?c=storyread&m=del&ajax=1&id=" + cid;
        $.get(url,function(data){
            if(data.status == 0) {
                $("#panel" + cid).remove();
            } else {
                alert(data.msg);
            }
        }, 'json');
    }
</script>
{/literal}
</body>
</html>
{/if}